/*
 * Copyright (c) 2011 HadronLabs
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */ 
 
 /*
 * TransitionCreator.as
 * Created On: 2011-05-28 13:52
 */
 package com.hadron.media.slideshow.patterns.factory 
 {
	import com.hadron.transitions.behaviors.ITransitionBehavior;
	import com.hadron.transitions.behaviors.lib.TB_Move;
	import com.hadron.transitions.enum.TransitionType;
	import com.hadron.transitions.ITransitionable;
	import temple.data.Enumerator;
	
	public class TransitionCreator 
	{
		private static var _instance:TransitionCreator;
 
		/* TransitionCreator
		 * Use TransitionCreator.instance
		 * @param singleton DO NOT USE THIS - Use TransitionCreator.instance */
		public function TransitionCreator(singleton:Singleton) 
		{
			if (singleton == null)
				throw new Error("TransitionCreator is a singleton class.  Access via ''TransitionCreator.instance''.");
		}
 
		/* instance
		 * Gets the TransitionCreator instance */
		public static function get instance():TransitionCreator 
		{
 			if (TransitionCreator._instance == null)
				TransitionCreator._instance = new TransitionCreator(new Singleton());
 			return TransitionCreator._instance;
 		}
		
		public function createBehavior(target:ITransitionable, type:String):ITransitionBehavior
		{
			var behavior:ITransitionBehavior = new TB_Move(target);
			behavior.type = getTransitionType(type);
			return behavior;
		}
		
		private function getTransitionType(value:String):TransitionType
		{
			return Enumerator.get(TransitionType, value) as TransitionType;
		}
	}
}
 
class Singleton { }